<div class="modal fade" id="modal-info-repository-row" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="sn-icon sn-icon-close"></i></button>
        <h4 class="modal-title">
          <%= t('repository_row.modal_info.head_title', repository_row: @repository_row.name) %>
          <%= @repository_row.archived? ? I18n.t('atwho.res.archived') : '' %>
        </h4>
      </div>

      <div class="modal-body">
        <ol class="breadcrumb breadcrumb-repository">
          <span class="sn-icon sn-icon-inventory" aria-hidden="true"></span>
          <%= t('repositories.repository', name: @repository_row.repository.name) %>
          <%= @repository_row.repository.archived? ? I18n.t('atwho.res.archived') : '' %>
        </ol>
        <div class="row">
          <div class="col-md-8">
            <p>
              <span>
                <%= t('repository_row.modal_info.ID') %>
                <%= @repository_row.code %>
              </span>
              <br>
              <span>
                <%= t('repository_row.modal_info.added_on') %>:
                <%= l(@repository_row.created_at, format: :full) %>
              </span>
              <br>
              <span>
                <%= t('repository_row.modal_info.added_by') %>:
                <%= @repository_row.created_by.full_name %>
              </span>
              <% @repository_row.repository_cells.each do |repository_cell| %>
                <br>
                <% if repository_cell.value_type == 'RepositoryStockValue' %>
                  <span><%= t('repository_row.modal_info.amount', value: repository_cell.value.formatted_value ) %></span>
                  <br>
                  <span><%= t('repository_row.modal_info.unit', unit: repository_cell.value.repository_stock_unit_item&.data ) %></span>
                <% else %>
                  <span>
                    <%= t 'repository_row.modal_info.column_name', cf: repository_cell.repository_column.name %>
                    <% if repository_cell.value_type == 'RepositoryAssetValue' %>
                      <%= render partial: 'assets/asset_link', locals: { asset: repository_cell.value.asset, display_image_tag: false }, formats: :html %>
                    <% else %>
                      <%= custom_auto_link(repository_cell.value.formatted, simple_format: false, team: current_team) %>
                    <% end %>
                  </span>
                <% end %>
              <% end %>
            </p>
          </div>
          <div class="col-md-4 bar-code-container">
            <canvas id="bar-code-canvas" class="hidden" data-id="<%= @repository_row.code %>"></canvas>
            <img id="bar-code-image" />
          </div>
        </div>

        <% if @repository_row.repository.is_a?(Repository) %>
          <% if @assigned_modules.size.positive? %>
            <div>
              <%= t('repository_row.modal_info.title', nr: @assigned_modules.size) %>
              <%= t('repository_row.modal_info.private_tasks', nr: @private_modules.size) if @private_modules.size.positive? %>
            </div>
            <% if @viewable_modules.size.positive? %>
            <div class="linked-children-datatable">
              <table id="repository_row-info-table" class="table dataTable no-footer" role="grid">
                <tbody>
                  <% @viewable_modules.each do |my_module|  %>
                    <tr role="row">
                      <td class="sorting_1">
                        <ol class='breadcrumb'>
                          <li>
                            <span class='sn-icon sn-icon sn-icon-users'></span>&nbsp;
                            <%= render partial: 'search/results/partials/team_text',
                                       locals: { team: my_module.experiment.project.team } %>
                          </li>
                          <li>
                            <%= image_tag 'icon_small/project.svg' %>
                            <%= render partial: 'search/results/partials/project_text',
                                      locals: { project: my_module.experiment.project } %>
                          </li>
                          <li>
                            <%= image_tag 'icon_small/experiment.svg' %>
                            <%= render partial: 'search/results/partials/experiment_text',
                                      locals: { experiment: my_module.experiment } %>
                          </li>
                          <li>
                            <%= image_tag 'icon_small/task.svg' %>
                            <%= render partial: 'search/results/partials/my_module_text',
                                      locals: { my_module: my_module,
                                                link_to_page: :repositories,
                                                repository: @repository_row.repository } %>
                          </li>
                        </ol>
                      </td>
                    </tr>
                  <% end %>
                </tbody>
                <thead>
                  <tr>
                    <th></th>
                  </tr>
                </thead>
              </table>
            </div>
            <% end %>
          <% else %>
            <em><%= t('repository_row.modal_info.no_tasks') %></em>
          <% end %>
        <% end %>
      </div>
      <div class="modal-footer" data-assign-item-button="<%= @my_module.present? %>">
        <% if can_export_repository_stock?(@repository_row.repository) %>
          <button
            type="button"
            class="btn btn-secondary export-consumption-button"
            data-object-id="<%= @repository_row.repository.id %>"
          >
            <%= t('repository_row.modal_info.export_consumption_label') %>
          </button>
        <% end %>
        <% if @my_module %>
          <button type="button" class="btn btn-secondary print-label-button"  data-rows="[<%= @repository_row.id %>]"><%= t('repository_row.modal_print_label.print_label') %></button>
          <button type="button" class="btn btn-secondary" data-dismiss="modal"><%= t('general.close')%></button>
          <span <% if @my_module_assign_error.present? %>
                  data-toggle="tooltip"
                  data-placement="bottom"
                  title="<%= @my_module_assign_error %>"
                <% end %>
          >
            <button type="button" class="btn btn-primary assign-inventory-button"
                    data-assign-url=<%= my_module_repositories_path(@my_module) %>
                    data-repository-row-id=<%= @repository_row.id %>
                    <%= 'disabled' if @my_module_assign_error.present? %>>
              <%= t('repository_row.modal_info.assign_to_task') %>
            </button>
          </span>
        <% else %>
          <button type="button" class="btn btn-secondary" data-dismiss="modal"><%= t('general.close')%></button>
          <button type="button" class="btn btn-primary print-label-button"  data-rows="[<%= @repository_row.id %>]"><%= t('repository_row.modal_print_label.print_label') %></button>
        <% end %>
      </div>
    </div>
  </div>
</div>
